C# ODBC Oracle 오라클 연동 :: DB연동[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

DB연동
[1]
등록일:2008-04-04 11:25:51 (0%)
작성자:
제목:C# ODBC Oracle 오라클 연동
C#  에서  Oracle과  의  연동을  위한  기초  코드이다.

  

모든  데이터베이스  관련  소스를  코딩할  때  가장  중요한것은  Database를  열고  나서  반드시  닫아주는  것이다.

실제로  2000명이  동시접속할  수  있는  서버에서  평상시  서버  다운이  자주  발생한다면  Database가  제대로  닫히지  않아  2000개의  Database가  열려  있는  가능성도  충분히  생각해  보아야한다.  이때  Finally  구문에  Connection을  닫아주는  구문만  적어주면  해결이  된다.

  

using  System;
using  System.Data;
using  System.Data.Odbc;

namespace  testOra
{
        public  class  testOracle
        {
                static  void  Main(string[]  args)
                {
                        string  testQuery="select  count(*)  from  emp";
                        string  connString  =  "Driver={Microsoft  ODBC  for  Oracle};Server=dama;UID=scott;PWD=*******";
                        OdbcConnection  myConnection  =  new  OdbcConnection(connString);
                        try
                        {
                                myConnection.Open();
                                Console.WriteLine("연결성공");
                                OdbcCommand  myCommand=new  OdbcCommand(testQuery,myConnection);
                                Console.WriteLine(myCommand.ExecuteScalar());                              
                                myConnection.Close();
                        }
                        catch  (OdbcException)
                        {
                                Console.WriteLine("연결실패");
                        }
                        finally
                        {
                                myConnection.Close();
                        }
                }
        }
}

[출처]  C#  ODBC  Oracle  |작성자  이용석
http://blog.naver.com/shadowds?Redirect=Log&logNo=10026840444
[본문링크] C# ODBC Oracle 오라클 연동
[1]
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=7175
작성자
비밀번호

 

SSISOCommunity

[이전]

Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.